﻿using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using MVCQuick.Framework.Container;

namespace MVCQuick.Framework.Tests
{
    [TestFixture]
    public class ContainerTests
    {
        [Test]
        public void Test1()
        {
            ClassicContainer.Register<Album>("album1");
            object o1 = ClassicContainer.GetObject("album1");
            Assert.IsNotNull(o1);
            Album album1 = o1 as Album;
            Assert.IsNotNull(album1);

            IDictionary propertyValues2 = new Hashtable();
            propertyValues2.Add("Id", 1);
            propertyValues2.Add("Title", "海阔天空");
            ClassicContainer.Register<Album>("album2", propertyValues2);
            Album album2 = ClassicContainer.GetObject("album2") as Album;
            Assert.IsNotNull(album2);
            Assert.AreEqual(album2.Id, 1);
            Assert.AreEqual(album2.Title, "海阔天空");

            ClassicContainer.Register<List<Album>>("albumList3");
            List<Album> albumList3 = ClassicContainer.GetObject("albumList3") as List<Album>;
            Assert.IsNotNull(albumList3);
            albumList3.Add(album2);
            Assert.AreEqual(albumList3[0].Id, 1);

        }
    }
}
